cmake_minimum_required(VERSION 3.4.1)

project(RingQueueTest)

#message(${PROJECT_SOURCE_DIR})

set(CMAKE_CXX_COMPILER g++)
set(CMAKE_C_COMPILER gcc)

#指定编译器，在执行cmake指令的时候，增加一个输入，-DBUILD_PLATFORM=arm
if (${BUILD_PLATFORM} MATCHES "arm")
    message("Build under the arm platform")
    set(CMAKE_SYSTEM_NAME Linux)
    set(CMAKE_SYSTEM_PROCESSOR $ENV{ARCH})
    set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
    set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
else()
    set(CMAKE_CXX_COMPILER g++)
    set(CMAKE_C_COMPILER gcc)
endif()

if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
    message("-- Build type debug!")
    set(CMAKE_CXX_FLAGS "-std=c++11 -g -rdynamic -Wall -O0")
    set(CMAKE_C_FLAGS "-std=gnu99 -g -rdynamic -Wall -O0")
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
    message("-- Build type release!")
    set(CMAKE_CXX_FLAGS "-std=c++11 -g -rdynamic -Wall -O3")
    set(CMAKE_C_FLAGS "-std=gnu99 -g -rdynamic -Wall -O3")
else()
    message("-- unknow build type: ${CMAKE_BUILD_TYPE}")
endif()

set(CMAKE_VERBOSE_MAKEFILE on)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
include_directories(${PROJECT_SOURCE_DIR}/src)

#file指令中GLOB表示只获取匹配目录下的代码文件，GLOB_RECURSE会遍历匹配目录的所有代码文件以及子目录下面的代码文件
file(GLOB_RECURSE FILE_LIST ${PROJECT_SOURCE_DIR}/src/*.cpp ${PROJECT_SOURCE_DIR}/src/*.h ${PROJECT_SOURCE_DIR}/src/*.hpp)
add_executable(${PROJECT_NAME} ${FILE_LIST})

TARGET_LINK_LIBRARIES(
    ${PROJECT_NAME}
    dl
    m
    rt
    pthread
)

#file(GLOB_RECURSE RingQueue_LIST ${PROJECT_SOURCE_DIR}/src/RingQueue.cpp ${PROJECT_SOURCE_DIR}/src/RingQueue.h)
#add_library(RingQueue SHARED ${RingQueue_LIST})
#add_executable(${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/src/main.cpp)
#target_link_libraries(${PROJECT_NAME} RingQueue)
